<template>
  <!-- 报名详情 -->
  <div class="applyDetail">
    <el-card shadow="never" style="margin-top: 30px">
      <div class="header">
        <div class="page-header">
          <el-page-header @back="goBack" content="报名详情" style="margin-bottom: 20px">
          </el-page-header>
        </div>
        <div class="buttons">

        </div>
      </div>

      <el-table
          :data="userList"
          style="width: 100%"
          highlight-current-row>
        <el-table-column
            label="序号"
            type="index"
            :index="indexMethod">
        </el-table-column>
        <el-table-column
            prop="userName"
            label="用户名"
        >
        </el-table-column>
        <el-table-column
            prop="realName"
            label="姓名"
        >
        </el-table-column>
        <el-table-column
            prop="userPhone"
            label="手机号">
        </el-table-column>
        <el-table-column
            prop="userSex"
            label="性别">
          <template slot-scope="scope">
            <span v-if="scope.row.userSex == 0"><el-tag type="danger" size="small" color="">女</el-tag></span>
            <span v-else><el-tag type="info" size="small" color="">男</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column
            prop="userType"
            label="身份类型"
            :filters="[{ text: '游客', value: 1 }, { text: '村民', value: 0 }]"
            :filter-method="filterTag"
            filter-placement="bottom-end">
          <template slot-scope="scope">
            <span v-if="scope.row.userType == 1"><el-tag size="small" color="">游客</el-tag></span>
            <span v-else><el-tag  type="success" size="small" color="">村民</el-tag></span>
          </template>
        </el-table-column>
      </el-table>


      <div style="padding: 10px 0">
        <el-pagination
            :page-sizes="[2, 5, 10, 20]"
            :page-size=this.pageSize
            layout="total, sizes, prev, pager, next, jumper"
            :total=this.total
            :current-page=this.pageNum
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        >
        </el-pagination>
      </div>

    </el-card>
  </div>
</template>

<script>
import {shortTime} from "@/utils/timeFormat";
import {getBiddingByTenderIdPage, getRegistrationByActivityId, updateFailBidding, updateWinBidding} from "@/api/allApi";
import {useUser} from "@/store/userStore"
export default {
  data(){
    return {
      userList:[],
      pageSize:5,
      total:0,
      pageNum:1,
      isActive:false,
      region:'',
      User:useUser(),
    }
  },
  methods:{
    goBack() {
      this.$router.back();
    },
    shortTime,
    indexMethod(index) {
      // 当前页数 - 1 * 每页数据条数 + 1
      const page = this.pageNum // 当前页码
      const pagesize = this.pageSize // 每页条数
      return index + 1 + (page - 1) * pagesize
    },
    handleSizeChange(pageSize){
      this.pageSize=pageSize;
      this.getRegistrationByActivityId();
    },
    handleCurrentChange(pageNum){
      this.pageNum=pageNum;
      this.getRegistrationByActivityId();
    },
    filterTag(value, row) {
      return row.userType === value;
    },
    getRegistrationByActivityId(){
      getRegistrationByActivityId({
        current:this.pageNum,
        pageSize:this.pageSize,
        activityId:this.$route.params.activityId
      }).then(res=>{
        this.userList = res.data.data
        this.total = res.data.total
      })
    },
  },
  mounted() {
    this.getRegistrationByActivityId()
  }
}
</script>

<style lang="less" scoped>
.header {
  display: flex;
  justify-content: space-between;
}

.page-header {
  width: 20%;
}

.buttons {
  margin: 0px 0 10px 0;
}
</style>